@include('admin.public.head')
@include('admin.public.laydate')

<div class="ibox-title">
    <h5>上课季度添加</h5>
</div>

<div class="ibox-content">
    <form  class="form-horizontal">

        <div class="form-group">
            <label class="col-sm-3 control-label">季度名称：</label>
            <div class="col-sm-2">
                <input type="text" name="name" class="form-control" placeholder="季度名称" value="">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">开始时间：</label>
            <div class="col-sm-2">
                <input type="text" name="start_time"  autocomplete="off"  id="start_time" class="form-control" placeholder="开始时间" value="">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">结束 时间：</label>
            <div class="col-sm-2">
                <input type="text" name="end_time" id="end_time"   autocomplete="off" class="form-control" placeholder="结束时间" value="">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <button class="btn btn-primary do" type="submit">操作</button>
                <a href="/quarterly" class="btn btn-primary" >返回季度列表</a>
            </div>
        </div>
    </form>
</div>

<script>
    $('.do').click(function(){
        var form = new FormData();

        var name = $('input[name="name"]').val();
        var start_time = $('input[name="start_time"]').val();
        var end_time = $('input[name="end_time"]').val();

        form.append("name", name);
        form.append("start_time", start_time);
        form.append("end_time", end_time);

        $.ajax({
            type: 'POST',
            url: '/quarterly_do' ,
            dataType:"json",   //返回格式为json
            data: form ,
            processData: false,
            contentType: false,
            success:function(data){

                if(data.status == '1') {
                    var swal_json = {
                        title: data.message,
                        type: "success"
                    }

                    swal(swal_json, function (isConfirm) {
                        window.location.reload();
                    });
                }else{
                    var swal_json = {
                        title: data.message,
                        type: "error"
                    }

                    swal(swal_json, function (isConfirm) {

                    });
                }

            }
        });

        return false;
    });
</script>
